<?=$this->load->view('user_include_top',null)?>  
<style> 
.item {color:blue; cursor:pointer}
.tr_hover {background-color: #DAEDF5;}
</style>   
<div style="width:100%;padding:5px; text-align: center;">  
<form name="form" method="post">
<div style="text-align: center;">
     条件查询：<select id="search_by"><option value='fullname'>姓名</option><option value='idcard'>身份证号</option></select>
     <input type="text" id="search_value"> <input type="button" value='查询' onclick="do_search()">
</div>
<TABLE cellspacing="1px" style="width:100%;background:#eeeeee;border:#eeeeee 5px solid" cellpadding="5px" id="form_list">
 <TR style="font-weight:bold">
    <TD>ID</TD><TD>客户姓名</TD><TD>身份证号</TD><TD>业务类别</TD><TD>目的国家</TD><TD>更新时间</TD><TD>操　作</TD>
</TR>
<?
$i = 0;
foreach($list as $v){?>
 <TR bgcolor="<?=($i%2==0)?'white':'#f4f4f4'?>" datarow="1">
    <TD><?=$v->id?></TD>
    <TD><a href="user/show_forms/<?=$v->card_id?>"><?=$v->surname?><?=$v->firstname?></a></TD>
    <TD><?=$v->national_id?></TD>
    <TD nowrap="nowrap"><?=$visa_type_array[$v->visa_type]?>,<?=$visa_purpose_array[$v->visa_purpose]?></TD>
    <TD><?=$v->country_cn_names?></TD>
    <TD nowrap=""><?=$v->update_time?></TD>
    <TD nowrap="nowrap">[<a href="javascript:download_pdf(<?=$v->card_id?>);">下载</a>] 
    [<a href="javascript:send_to_mail(<?=$v->card_id?>);">邮件</a>] 
    [<a href="user/show_forms/<?=$v->card_id?>">修改</a>] 
    [<a href="javascript:delete_forms(<?=$v->card_id?>)">删除</a>]</TD> 
</TR>
<?
    $i++;
}?>
</TABLE>
<div style="text-align: center;"><?=$page_links?></div>
</form>

<script>
var f = document.form;   

function delete_forms(v) {
    if(confirm('确认要删除吗？')) {
        $.get('user/delete_forms/'+v, function(data){
            if(data == "ok") {
                alert('记录删除成功！');
                window.location.reload();
            } 
        });
    }
}

function do_search() {
   if($('#search_value').val() == '') {
       alert('请输入查询关键字！');
       return false;
   }
   window.location = "<?=base_url()?>user/list_forms?search_by="+$('#search_by').val()+"&search_value="+$('#search_value').val();
}

// 此方法用于取到idcard关联的表格id串，一起传入java后台
function generate_pdf() {
    $.get("<?=base_url()?>user/get_form_ids_by_idcard/"+card_id, function(data){
        var ids = data.split(",");
        form_ids = ids.join("_"); // 此id串要传入后台备用
        var forms_data = [];   
        for(var i=0; i<ids.length; i++) {
           forms_data.push( "{\"rel_id\":"+ids[i]+", \"rec_id\":"+card_id+"}" );   
        }
        var json_data = "["+forms_data.join(",")+"]";
        invoke_java_servive(json_data);
    })
}

$(document).ready(function(){    
    $("#form_list tr[datarow=1]").hover(function() {   
        $(this).addClass("tr_hover"); // 鼠标经过添加hover样式    
    }, function() {   
        $(this).removeClass("tr_hover"); // 鼠标离开移除hover样式    
    })    
});  
</script>

<?=$this->load->view('user_include_pdf',null)?>       
 
<?=$this->load->view('user_include_bottom',null)?>     